package cn.ycc1.auth.controller;

import cn.ycc1.core.api.ApiResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationManager;
import org.springframework.web.bind.annotation.*;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @Title:
 * @Author ycc
 * @Date 2023/7/8 10:26
 */
@RestController
@RequestMapping("/oauth")
@Slf4j
public class AuthController {

//    @Autowired
//    OAuth2AccessToken oAuth2AccessToken;

    @PostMapping("/login")
    public String login(@RequestParam String username, @RequestParam String password) {
        log.info(username + "---" + password);

//        OAuth2Token accessToken = oAuth2AuthenticationManager.getAccessToken();
//
//        OAuth2User user = oAuth2AuthenticationManager.getUserDetails(accessToken);

//        OAuth2AccessToken auth2AccessToken = this.getOauth2AccessToken(yxUserApiResult.getData().getUsername(), password);
//        Map<String, Object> map = new LinkedHashMap<>(2);
//        //保存在线用户信息
//        //remoteMemberUserService.saveLoginOnUser(yxUserApiResult.getData(), auth2AccessToken.getValue());
//        map.put("token", auth2AccessToken.getValue());
//        map.put("expires_time", DateUtil.formatDateTime(auth2AccessToken.getExpiration()));
        return "login";
    }
}
